-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Introduce debuginfo to statements in MIR #142771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
15c968a
to
6b013d4
Compare
This comment has been minimized.
This comment has been minimized.
6b013d4
to
51576e7
Compare
This comment has been minimized.
This comment has been minimized.
@bors2 try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Introduce debuginfo to statements in MIR Not ready for reviewing. Something known: - [ ] Retain debuginfo when concatenating bbs - [ ] Document about when to drop debuginfos (don't be worse than the optimized LLVM IR) - [ ] Missing tests r? ghost
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (eb83156): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 2.3%, secondary 3.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 3.2%, secondary 2.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.5%, secondary 0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 691.482s -> 692.445s (0.14%) |
51576e7
to
e72c3ae
Compare
@bors2 try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Introduce debuginfo to statements in MIR Not ready for reviewing. Something known: - [ ] Retain debuginfo when concatenating bbs - [ ] Document about when to drop debuginfos (don't be worse than the optimized LLVM IR) - [ ] Missing tests r? ghost
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (77d5c6a): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 2.4%, secondary 3.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.1%, secondary 0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.5%, secondary 0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 690.617s -> 691.47s (0.12%) |
☔ The latest upstream changes (presumably #142870) made this pull request unmergeable. Please resolve the merge conflicts. |
This comment has been minimized.
This comment has been minimized.
bug!("debuginfo is not yet supported.") | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder: should we attempt to keep debuginfo in most cases, and only drop statements that we do not know how to convert? I mean, consider drop_debuginfo
to be always false, and replace the bug!
by a no-op?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to do this after we've reviewed most of the MIR statements.
@@ -62,16 +64,22 @@ | |||
+ StorageLive(_8); | |||
+ StorageLive(_9); | |||
+ StorageLive(_11); | |||
+ _11 = copy (((((*_6).0: alloc::raw_vec::RawVec<A>).0: alloc::raw_vec::RawVecInner).0: std::ptr::Unique<u8>).0: std::ptr::NonNull<u8>); | |||
+ _9 = copy _11 as *mut A (Transmute); | |||
+ // DBG: AssignRef(_11, ((*_6).0: alloc::raw_vec::RawVec<A>)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: could you make this a little more pretty? Reuse the _11 = &stuff
syntax?
data.retain_statements(|statement| { | ||
let keep = match &statement.kind { | ||
for statement in data.statements.iter_mut() { | ||
let drop_debuginfo = match &statement.kind { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be more readable as a let (keep_statement, drop_debuginfo) =
? Instead of short-circuit inside the match?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -52,7 +52,7 @@ impl<'tcx> crate::MirPass<'tcx> for CopyProp { | |||
Replacer { tcx, copy_classes: ssa.copy_classes(), fully_moved, storage_to_remove } | |||
.visit_body_preserves_cfg(body); | |||
|
|||
crate::simplify::remove_unused_definitions(body); | |||
crate::simplify::remove_unused_definitions(body, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we reason according to mir-opt-level
, or the debuginfo the user requires like the inliner does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated it on c6220a4.
.after_last_stmt_debuginfos | ||
.extend_from_slice(&debuginfos); | ||
} | ||
debuginfos.extend_from_slice(&self.basic_blocks[current].after_last_stmt_debuginfos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this directly extend pred_debuginfos
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a new revision that directly extends pred_debuginfos
.
let mut debuginfos = if let Some(first_succ) = terminator.successors().next() | ||
&& terminator.successors().all(|s| s == first_succ) | ||
{ | ||
Some(Vec::new()) | ||
} else { | ||
None | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, you only add debuginfo if all successors are the same. Do you mind adding a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parent_bb_last_debuginfos.append(&mut stmt.debuginfos); | ||
std::mem::swap(&mut parent_bb_last_debuginfos, &mut stmt.debuginfos); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment explaining this is a faster version of a "prepend"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot find the "prepend" method. :?
// CHECK-LABEL: fn drop_debuginfo | ||
// CHECK: debug foo_b => [[foo_b:_[0-9]+]]; | ||
// CHECK: bb0: { | ||
// CHECK-NEXT: DBG: AssignRef([[foo_b]], ((*_1).1: i64)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a CHECK-NOT
for the absence of the other debuginfo statement? Eventually a comment stating why we expect that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's enough to use CHECK-NEXT
already here. The latest commit includes a comment.
0989b8f
to
05e7608
Compare
This comment has been minimized.
This comment has been minimized.
05e7608
to
910cac7
Compare
@bors2 try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Introduce debuginfo to statements in MIR The PR introduces support for debug information within dead statements. Currently, only the reference statement is supported, which is sufficient to fix #128081. I don't modify Stable MIR, as I don't think we need debug information when using it. This PR represents the debug information for the dead reference statement via `#dbg_value`. For example, `let _foo_b = &foo.b` becomes `#dbg_value(ptr %foo, !22, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), !26)`. You can see this here: https://rust.godbolt.org/z/d43js6adv. The general principle for handling debug information is to never provide less debug information than the optimized LLVM IR. The current rules for dropping debug information in this PR are: - If the LLVM IR cannot represent a reference address, it's replaced with poison or simply dropped. For example, see: https://rust.godbolt.org/z/shGqPec8W. I'm using poison in all such cases now. - All debuginfos is dropped when merging multiple successor BBs. An example is available here: https://rust.godbolt.org/z/TE1q3Wq6M. > I haven't drop debuginfos in `MatchBranchSimplification`, because LLVM also pick one branch for it. For [the perf result](#142771 (comment)): I expected this to introduce some regressions; however, the results mixed the effects of inlining. Looking at the doc profile, this is a clear optimization. One potential regression I'm investigating is `serde-1.0.219-debug-full`.
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (91b1a3e): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 2.1%, secondary 2.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.6%, secondary 5.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.5%, secondary 0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 462.57s -> 466.721s (0.90%) |
910cac7
to
3a1ab06
Compare
@bors2 try @rust-timer queue |
Introduce debuginfo to statements in MIR The PR introduces support for debug information within dead statements. Currently, only the reference statement is supported, which is sufficient to fix #128081. I don't modify Stable MIR, as I don't think we need debug information when using it. This PR represents the debug information for the dead reference statement via `#dbg_value`. For example, `let _foo_b = &foo.b` becomes `#dbg_value(ptr %foo, !22, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), !26)`. You can see this here: https://rust.godbolt.org/z/d43js6adv. The general principle for handling debug information is to never provide less debug information than the optimized LLVM IR. The current rules for dropping debug information in this PR are: - If the LLVM IR cannot represent a reference address, it's replaced with poison or simply dropped. For example, see: https://rust.godbolt.org/z/shGqPec8W. I'm using poison in all such cases now. - All debuginfos is dropped when merging multiple successor BBs. An example is available here: https://rust.godbolt.org/z/TE1q3Wq6M. > I haven't drop debuginfos in `MatchBranchSimplification`, because LLVM also pick one branch for it. For [the perf result](#142771 (comment)): I expected this to introduce some regressions; however, the results mixed the effects of inlining. Looking at the doc profile, this is a clear optimization. One potential regression I'm investigating is `serde-1.0.219-debug-full`.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (9f0ec68): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 2.3%, secondary 3.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -0.3%, secondary -2.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.5%, secondary 0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 465.928s -> 464.642s (-0.28%) |
The PR introduces support for debug information within dead statements. Currently, only the reference statement is supported, which is sufficient to fix #128081.
I don't modify Stable MIR, as I don't think we need debug information when using it.
This PR represents the debug information for the dead reference statement via
#dbg_value
. For example,let _foo_b = &foo.b
becomes#dbg_value(ptr %foo, !22, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), !26)
. You can see this here: https://rust.godbolt.org/z/d43js6adv.The general principle for handling debug information is to never provide less debug information than the optimized LLVM IR.
The current rules for dropping debug information in this PR are:
For the perf result:
I expected this to introduce some regressions; however, the results mixed the effects of inlining. Looking at the doc profile, this is a clear optimization. One potential regression I'm investigating is
serde-1.0.219-debug-full
.